package com.example.servicefeign.controller;

import com.example.servicefeign.model.User;
import com.example.servicefeign.service.SchedualServiceHello;
import com.example.servicefeign.service.SchedualServiceHi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class HiController {

    @Autowired
    SchedualServiceHi serviceHi;

    @Autowired
    SchedualServiceHello serviceHello;

    @PostMapping(value = "/getUser1")
    public User getUser(@RequestBody User user){
        return serviceHello.getUser(user);
    }

    @GetMapping(value = "/sayHi")
    public String sayHi(@RequestParam String name) {
        return serviceHi.sayHiFromClientOne( name );
    }

    @GetMapping(value = "/hello")
    public String hello(){
        return serviceHello.hello();
    }

    @PostMapping(value = "/getUser")
    public User getUserFromClientOne(@RequestBody User user){
        return serviceHi.getUserFromClientOne(user);
    }

    @PostMapping(value = "/getParam")
    public String getParam(@RequestParam(value = "name") String name){
        return serviceHi.getUserFromClientOne(name);
    }

}
